<template>
	<el-table :data="tableData" border highlight-current-row @selection-change="selectionChange">
		<el-table-column type="selection" width="60" align="center"></el-table-column>
            <el-table-column type="index" label="序号" width="60" align="center"></el-table-column>
            <el-table-column property="name" label="审核人" align="center">
                <template slot-scope="scope">
                    <span>{{findNameById(scope.row.name)}}</span>
                </template>
            </el-table-column>
            <el-table-column property="name1" label="并列审核人1" align="center">
                <template slot-scope="scope">
                    <span>{{findNameById(scope.row.name1)}}</span>
                </template>
            </el-table-column>
            <el-table-column property="name2" label="并列审核人2" align="center">
                <template slot-scope="scope">
                    <span>{{findNameById(scope.row.name2)}}</span>
                </template>
            </el-table-column>
            <el-table-column property="name3" label="并列审核人3" align="center">
                <template slot-scope="scope">
                    <span>{{findNameById(scope.row.name3)}}</span>
                </template>
            </el-table-column>
            <el-table-column property="nodeType" label="节点类型" align="center">
                <template slot-scope="scope">
                    <span v-if="scope.row.nodeType == 0" style="color: #67c23a;">审核</span>
                    <span v-if="scope.row.nodeType == 1" style="color: #409eff;">知会</span>
                    <span v-if="scope.row.nodeType == 2" style="color: #e6a23c;">抄送</span>
                </template>
            </el-table-column>
            <el-table-column property="generateDocument" label="生成单据" align="center">
                <template slot-scope="scope">
                    <el-checkbox v-model="!!scope.row.generateDocument" disabled="disabled"></el-checkbox>
                </template>
            </el-table-column>
	</el-table>
</template>
<script>
export default {
	data() {
		return {
			tableData: this.$store.state.verifyProcessStore.reviewerTableData,
			reviewer: [],        //审核人
            nameObj: {}
		}
	},
    computed: {
        systemId() {
            return this.$store.state.systemId;
        }
    },
    methods: {
        getReviewerData() {     //获取审核人数据
            this.$http.get('employee/findEmployeeByDepartment?systemId=' + this.systemId + '&id=0').then(res => {
                if(res.data.code == 20001) {
                    if(res.data.data) {
                        this.reviewer = res.data.data;
                    }
                }
            });
        },
        selectionChange(arr) {      //选中的表格行数据
            console.log(arr);
        },
        findNameById(id) {          //通过审核人id找到审核人名称
            let name = null;
            this.reviewer.forEach(item => {
                if(item['id'] == id) {
                    name = item['name'];
                }
            });
            return name;
        }
    },
    created() {
        this.getReviewerData();
    }
}
</script>